import java.io.IOException;
import java.util.List;

import com.hp.hpl.jena.ontology.OntModel;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelChangedListener;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Statement;
import com.hp.hpl.jena.rdf.model.StmtIterator;


public class MyContextListener implements ModelChangedListener{
	
	private TestReasoner reasoner;
	private Model model;
	private OntModel ontModel;
	
	public MyContextListener(Model model) {
		// TODO Auto-generated constructor stub
		TestReasoner tempReasoner = new TestReasoner();
		this.reasoner = tempReasoner;
		this.model = model;
		this.ontModel = ModelFactory.createOntologyModel();
		
	}
	
	public OntModel getOntModel(){
		return this.ontModel;
	}
	
	@Override
	public void addedStatement(Statement arg0) {
		// TODO Auto-generated method stub
		System.out.println("Success to add statement!");
		try {
			ontModel = reasoner.runEngine("smartspacehasLocatedIn.rules", model);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}

	@Override
	public void addedStatements(Statement[] arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void addedStatements(List<Statement> arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void addedStatements(StmtIterator arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void addedStatements(Model arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void notifyEvent(Model arg0, Object arg1) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removedStatement(Statement arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removedStatements(Statement[] arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removedStatements(List<Statement> arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removedStatements(StmtIterator arg0) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void removedStatements(Model arg0) {
		// TODO Auto-generated method stub
		
	}

}
